//
//  DelegateMainView.m
//  ProjectForCustomer
//
//  Created by 钟游 on 2019/8/25.
//  Copyright © 2019年 钟游. All rights reserved.
//

#import "DelegateMainView.h"
#import "LoginViewModel.h"
@interface DelegateMainView()

{
    UIWebView * myWebView;
}
@property(nonatomic,strong)LoginViewModel * viewModel;
@end
@implementation DelegateMainView

-(instancetype)initWithViewModel:(id<ViewModelProtocol>)viewModel{
    self.viewModel =(LoginViewModel*)viewModel;
    return  [super initWithViewModel:viewModel];
}
-(void)zy_bindViewModel{
    [[self.viewModel.wbSubject takeUntil:self.rac_willDeallocSignal]subscribeNext:^(id  _Nullable x) {
        NSURL *filePath = [NSURL URLWithString:[NSString stringWithFormat:@"%@",x]];
        NSURLRequest *request = [NSURLRequest requestWithURL: filePath];
        [self->myWebView loadRequest:request];
    }];
    
}
-(void)zy_setupViews{
    myWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, NAVBAR_HEIGHT, KscreenWidth, KscreenHeight-NAVBAR_HEIGHT)];
    myWebView.backgroundColor = [UIColor whiteColor];
  
    //使文档的显示范围适合UIWebView的bounds
    [myWebView setScalesPageToFit:YES];
    [self addSubview:myWebView];
}
#pragma mark -- lazy
-(LoginViewModel *)viewModel{
    if (!_viewModel) {
        _viewModel=[[LoginViewModel alloc]init];
    }
    return _viewModel;
}
@end
